package remote.controls
{
	import remote.enums.HAlgin;
	import remote.enums.VAlgin;
	import remote.layouts.HorizontalLayout;
	import remote.skins.CheckBoxIconSkin;
	import remote.skins.EmptySkin;
	import remote.skins.SolidRectangleSkin;
	import remote.skins.brushes.SolidBrush;
	
	/**
	 * 多选框
	 * @createDate 2011-3-2
	 * @author 徐俊杰
	 */
	public class CheckBox extends Button
	{
		private var _icon:Button;
		public function CheckBox()
		{
			super();
			this._toggle = true;
			this.updateToggle();
		}
		
		/**
		 * @inheritDoc 
		 * 
		 */	
		override public function setMouseStatus(value:String):void
		{
			if(this._mouseStatus != value)
				_icon.setMouseStatus(value);
			super.setMouseStatus(value);
		}
		
		/**
		 * @inheritDoc 
		 * 
		 */	
		override protected function createSkin():void
		{
			_skin = new SolidRectangleSkin(new SolidBrush(0, 0, 0, 0, 0));
		}
		
		/**
		 * @inheritDoc 
		 * 
		 */	
		override protected function createLayout():void
		{
			_layout = new HorizontalLayout(this, 5, VAlgin.MIDDLE, HAlgin.CENTER);
		}
		
		/**
		 * @inheritDoc 
		 * 
		 */	
		override protected function createChildren():void
		{
			super.createChildren();
			_icon = new Button();
			_icon.setSize(10, 10);
			_icon.skin = new CheckBoxIconSkin();
			addChildAt(_icon, 0);
		}
		
		/**
		 * @inheritDoc 
		 * 
		 */	
		override public function set selected(value:Boolean):void
		{
			super.selected = value;
			_icon.selected = value;
		}
		
		/**
		 * @inheritDoc 
		 * 
		 */	
		override public function set toggle(value:Boolean):void
		{
			throw new Error("CheckBox不能修改toggle属性");
		}
		
		/**
		 * @inheritDoc 
		 * 
		 */	
		public function get icon():Button
		{
			return _icon;
		}

	}
}